/* $Id: JMapPropertiesDialog.java 63 2010-02-14 13:52:34Z aaron.day $ */
package org.crazydays.gameplan.map.swing;


import java.awt.Frame;
import java.awt.Point;

import javax.swing.JDialog;

import org.crazydays.gameplan.map.GameMap;
import org.crazydays.gameplan.view.View;

/**
 * JMapPropertiesDialog
 */
public class JMapPropertiesDialog
    extends JDialog
{
    /** serial version uid */
    public final static long serialVersionUID =
        "$Id: JMapPropertiesDialog.java 63 2010-02-14 13:52:34Z aaron.day $"
            .hashCode();

    /** game map */
    protected GameMap gameMap;

    /** game map properties panel */
    protected JGameMapPropertiesPanel gameMapPropertiesPanel;

    /**
     * JMapPropertiesDialog constructor.
     * 
     * @param view View
     * @param gameMap Game map
     */
    public JMapPropertiesDialog(View view, GameMap gameMap)
    {
        super((Frame) view.getParent(), gameMap.getName());
        this.gameMap = gameMap;
    }

    /**
     * Initialize map properties dialog.
     */
    public void initialize()
    {
        initializeGameMapPropertiesPanel();
        pack();
        initializeLocation();
    }

    /**
     * Initialize game map properties panel.
     */
    protected void initializeGameMapPropertiesPanel()
    {
        gameMapPropertiesPanel = new JGameMapPropertiesPanel(gameMap);
        gameMapPropertiesPanel.initialize();

        add(gameMapPropertiesPanel);
    }

    /**
     * Initialize location.
     */
    protected void initializeLocation()
    {
        int x =
            getParent().getX() + (getParent().getWidth() / 2)
                - (getWidth() / 2);
        int y =
            getParent().getY() + (getParent().getHeight() / 2)
                - (getHeight() / 2);

        setLocation(new Point(x, y));
    }
}
